package com.qfedu.service.impl;

import com.github.pagehelper.PageHelper;
import com.qfedu.dao.ExercisesDao;
import com.qfedu.entity.Exercises;
import com.qfedu.service.ExercisesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: backStage
 * author: CGY
 * time: 2020/10/7 10:08
 * description:
 */
@Service
public class ExercisesServiceImpl implements ExercisesService {
    @Autowired
    private ExercisesDao exercisesDao;

    @Override
    public void addExercises(Exercises exercises) {
        exercisesDao.addExercises(exercises);
    }

    @Override
    public List<Exercises> selectExercises(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return exercisesDao.selectExercises();
    }

    @Override
    public void deleteByEid(Integer id) {
        if (id == null){
            throw new RuntimeException("id为null");
        }
        exercisesDao.deleteByEid(id);
    }
}
